import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

// 解决多次重复点击路由报错
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err);
};

export default new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes: [
    {
      path: '/',
      name: 'Home',
      component: Home,
      children: [
        /* 控制台 */
        {
          title: '控制台',
          name: 'control',
          path: 'control/home',
          component: () => import('../views/control/index'),
        },

        /* 企业 */
        {
          title: '企业',
          name: 'enterprise-manage',
          path: 'enterprise-manage/company',
          component: () => import('../views/enterprise-manage/company'),
        },

        /* 记账公司 */
        {
          title: '记账公司',
          name: 'enterprise-manage',
          path: 'enterprise-manage/comp',
          component: () => import('../views/enterprise-manage/comp'),
        },

        /* 订单管理 */
        {
          title: '订单管理',
          name: 'operation-manage',
          path: 'operation-manage/indent',
          component: () => import('../views/operation-manage/indent'),
        },

        /* 发票管理 */
        {
          title: '发票管理',
          name: 'operation-manage',
          path: 'operation-manage/invoice',
          component: () => import('../views/operation-manage/invoice'),
        },

        /* 资产负债表(企业) */
        {
          title: '资产负债表(企业)',
          name: 'bao-manage',
          path: 'bao-manage/balance',
          component: () => import('../views/bao-manage/balance'),
        },

        /* 资产负债表(小企业) */
        {
          title: '资产负债表(小企业)',
          name: 'bao-manage',
          path: 'bao-manage/balanced',
          component: () => import('../views/bao-manage/balanced'),
        },

        /* 利润表(企业) */
        {
          title: '利润表(企业)',
          name: 'bao-manage',
          path: 'bao-manage/profit',
          component: () => import('../views/bao-manage/profit'),
        },

        /* 利润表(小企业) */
        {
          title: '利润表(小企业)',
          name: 'bao-manage',
          path: 'bao-manage/profite',
          component: () => import('../views/bao-manage/profite'),
        },

        /* 利润表(季报) */
        {
          title: '利润表(季报)',
          name: 'bao-manage',
          path: 'bao-manage/profited',
          component: () => import('../views/bao-manage/profited'),
        },

        /* 现金流量表 */
        {
          title: '现金流量表',
          name: 'bao-manage',
          path: 'bao-manage/flow',
          component: () => import('../views/bao-manage/flow'),
        },

        /* 现金流量表(季度) */
        {
          title: '现金流量表(季度)',
          name: 'bao-manage',
          path: 'bao-manage/flowe',
          component: () => import('../views/bao-manage/flowe'),
        },

        /* 经营状况 */
        {
          title: '经营状况',
          name: 'bao-manage',
          path: 'bao-manage/state',
          component: () => import('../views/bao-manage/state'),
        },

        /* 纳税统计表 */
        {
          title: '纳税统计表',
          name: 'bao-manage',
          path: 'bao-manage/pay',
          component: () => import('../views/bao-manage/pay'),
        },

        /* 计算公式 */
        {
          title: '计算公式',
          name: 'bao-manage',
          path: 'bao-manage/formula',
          component: () => import('../views/bao-manage/formula'),
        },

        /* 凭证引擎 */
        {
          title: '凭证引擎',
          name: 'settings',
          path: 'settings/voucher',
          component: () => import('../views/settings/voucher'),
        },

        /* 科目设置 */
        {
          title: '科目设置',
          name: 'settings',
          path: 'settings/subject',
          component: () => import('../views/settings/subject'),
        },

        /* 操作日志 */
        {
          title: '操作日志',
          name: 'settings',
          path: 'settings/logger',
          component: () => import('../views/settings/logger'),
        },

        /* 角色管理 */
        {
          title: '角色管理',
          name: 'settings',
          path: 'settings/purpose',
          component: () => import('../views/settings/purpose'),
        },

        /* 系统消息 */
        {
          title: '系统消息',
          name: 'door',
          path: 'door/door',
          component: () => import('../views/door/door'),
        },

        /* 系统用户 */
        {
          title: '系统用户',
          name: 'door',
          path: 'door/door',
          component: () => import('../views/door/door'),
        },

        /* 门户管理 */
        {
          title: '门户管理',
          name: 'door',
          path: 'door/door',
          component: () => import('../views/door/door'),
        },
      ],
    },
  ],
});